﻿using System;
using System.Collections.Generic;
using System.Data.Entity.ModelConfiguration;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using ZSZ.Service.Entity;

namespace ZSZ.Service.EntityConfig
{
   class AdminUserConfig: EntityTypeConfiguration<AdminUserEntity>
    {
        public AdminUserConfig() {
            this.ToTable("T_AdminUsers");
            HasOptional(a => a.City).WithMany().HasForeignKey(s=>s.CityId);
            this.Property(a => a.LastLoginErrorTime).IsOptional();
            HasMany(a => a.Roles).WithMany(r => r.AdminUsers).Map(m=>m.ToTable("T_AdminUserRoles").MapLeftKey("AdminUserId").MapRightKey("RoleId"));
            this.Property(a => a.PasswordHash).IsUnicode();
            this.Property(a => a.PasswordYan).IsUnicode();
        }
    }
}
